
Stack_Size		EQU     0x800

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp


; <h> Heap Configuration
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Heap_Size      EQU     0x100

                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit

                PRESERVE8
                THUMB


; Vector Table Mapped to Address 0 at Reset
                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors
                EXPORT  __Vectors_End
                EXPORT  __Vectors_Size

__Vectors       DCD     __initial_sp                   ; Top of Stack
                DCD     Reset_Handler                  ; Reset Handler
                DCD     NMI_Handler                    ; NMI Handler
                DCD     HardFault_Handler              ; Hard Fault Handler
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     SVC_Handler                    ; SVCall Handler
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     PendSV_Handler                 ; PendSV Handler
                DCD     SysTick_Handler                ; SysTick Handler

                ; External Interrupts
                DCD     WWDG_IRQHandler                ; Window Watchdog											0
                DCD     0                              ; Reserved													1
                DCD     RTC_IRQHandler                 ; RTC through EXTI Line										2
                DCD     0                              ; Reserved													3
                DCD     MIC_IRQHandler                 ; Reserved													4
                DCD     EXTI0_1_IRQHandler             ; EXTI Line 0 and 1											5
                DCD     EXTI2_3_IRQHandler             ; EXTI Line 2 and 3											6
                DCD     EXTI4_15_IRQHandler            ; EXTI Line 4 to 15											7
                DCD     TK_IRQHandler                  ; EXTI Line TK												8
                DCD     DMA1_Channel1_IRQHandler       ; DMA1 Channel 0												9
                DCD     DMA1_Channel2_IRQHandler       ; DMA1_Channel1												10
                DCD     DMA2_Channel1_IRQHandler       ; DMA2_Channel0    											11
				DCD		DMA2_Channel2_IRQHandler	   ; DMA2_Channel1 												12
                DCD     TIM1_UP_IRQHandler		   	   ; TIM1 , Update, Trigger  									13
                DCD     TIM1_CC_IRQHandler             ; TIM1 Capture Compare										14
                DCD     PWMLED_IRQHandler              ; PWM														15
                DCD     SPI2_IRQHandler 			   ; TIM3 Break, Update, Trigger and Commutation				16
				DCD     TIM6_IRQHandler                ; TIM3														17
                DCD     LVD_IRQHandler                 ; LVD														18
				DCD     TIM14_CC_UP_IRQHandler		   ; TIM14														29
                DCD     ADC_IRQHandler                 ; ADC														20
                DCD     SPI3_IRQHandler    			   ; Reserved													21
			    DCD     TIM7_IRQHandler                ; Reserved  0												22
                DCD     I2C_IRQHandler                 ; I2C														23
				DCD     CMP_IRQHandler     			   ; Reserved													24
                DCD     SPI1_IRQHandler                ; SPI1														25
			    DCD     UART0_IRQHandler              ; UART0														26
                DCD     UART1_IRQHandler              ; UART1														27
                DCD     UART2_IRQHandler              ; UART2														28
				DCD     0x5975616E                  ;
				DCD     0x486F6E67                  ;						

__Vectors_End

__Vectors_Size  EQU  __Vectors_End - __Vectors

                AREA    |.text|, CODE, READONLY

; Reset handler routine
Reset_Handler    PROC
                 EXPORT  Reset_Handler                 [WEAK]
        IMPORT  __main
        IMPORT  SystemInit  
                 LDR     R0, =SystemInit
                 BLX     R0
                 LDR     R0, =__main
                 BX      R0
                 ENDP

; Dummy Exception Handlers (infinite loops which can be modified)

NMI_Handler     PROC
                EXPORT  NMI_Handler                    [WEAK]
                B       .
                ENDP
HardFault_Handler\
                PROC
                EXPORT  HardFault_Handler              [WEAK]
                B       .
                ENDP
SVC_Handler     PROC
                EXPORT  SVC_Handler                    [WEAK]
                B       .
                ENDP
PendSV_Handler  PROC
                EXPORT  PendSV_Handler                 [WEAK]
                B       .
                ENDP
SysTick_Handler PROC
                EXPORT  SysTick_Handler                [WEAK]
                B       .
                ENDP

Default_Handler PROC


                EXPORT  WWDG_IRQHandler         [WEAK]
                EXPORT  RTC_IRQHandler          [WEAK]
				EXPORT  MIC_IRQHandler          [WEAK]	
				EXPORT  EXTI0_1_IRQHandler      [WEAK]
                EXPORT  EXTI2_3_IRQHandler      [WEAK]
                EXPORT  EXTI4_15_IRQHandler     [WEAK]
                EXPORT  TK_IRQHandler           [WEAK]
				EXPORT	DMA1_Channel1_IRQHandler[WEAK]
                EXPORT  DMA1_Channel2_IRQHandler[WEAK]
                EXPORT  DMA2_Channel1_IRQHandler[WEAK]
                EXPORT  DMA2_Channel2_IRQHandler[WEAK]
                EXPORT  TIM1_UP_IRQHandler	    [WEAK]
				EXPORT  TIM1_CC_IRQHandler      [WEAK]
                EXPORT  PWMLED_IRQHandler       [WEAK]
                EXPORT  SPI2_IRQHandler 		[WEAK]
				EXPORT  TIM6_IRQHandler         [WEAK]
				EXPORT	LVD_IRQHandler          [WEAK]
                EXPORT  TIM14_CC_UP_IRQHandler	[WEAK]
				EXPORT  ADC_IRQHandler          [WEAK]
				EXPORT  SPI3_IRQHandler         [WEAK]
                EXPORT  TIM7_IRQHandler         [WEAK]
                EXPORT  I2C_IRQHandler          [WEAK]
				EXPORT	CMP_IRQHandler			[WEAK]
				EXPORT  SPI1_IRQHandler         [WEAK]
				EXPORT  UART0_IRQHandler       [WEAK]
				EXPORT  UART1_IRQHandler       [WEAK]
				EXPORT  UART2_IRQHandler       [WEAK]
					
					        


WWDG_IRQHandler         
RTC_IRQHandler 
MIC_IRQHandler
EXTI0_1_IRQHandler      
EXTI2_3_IRQHandler      
EXTI4_15_IRQHandler     
TK_IRQHandler           
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA2_Channel1_IRQHandler
DMA2_Channel2_IRQHandler
TIM1_UP_IRQHandler	
TIM1_CC_IRQHandler      
PWMLED_IRQHandler          
SPI2_IRQHandler 		
TIM6_IRQHandler         
LVD_IRQHandler          
TIM14_CC_UP_IRQHandler	
ADC_IRQHandler 
SPI3_IRQHandler
TIM7_IRQHandler         
I2C_IRQHandler 
CMP_IRQHandler
SPI1_IRQHandler         
UART0_IRQHandler       
UART1_IRQHandler       
UART2_IRQHandler       



                B       .

                ENDP

                ALIGN

;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
                 IF      :DEF:__MICROLIB

                 EXPORT  __initial_sp
                 EXPORT  __heap_base
                 EXPORT  __heap_limit

                 ELSE

                 IMPORT  __use_two_region_memory
                 EXPORT  __user_initial_stackheap

__user_initial_stackheap

                 LDR     R0, =  Heap_Mem
                 LDR     R1, =(Stack_Mem + Stack_Size)
                 LDR     R2, = (Heap_Mem +  Heap_Size)
                 LDR     R3, = Stack_Mem
                 BX      LR

                 ALIGN

                 ENDIF

                 END
